import React, { Component } from "react";
import Modal from "./Modal";

class App extends Component {
  state = {
    show: false,
  };

  open = () => {
    this.setState({
      show: true,
    });
  };

  handleOk = () => {
    this.setState({
      show: false,
    });
  };

  handleCancel = () => {
    this.setState({
      show: false,
    });
  };

  fn = () => {
    console.log("fn");
  };

  render() {
    return (
      // 事件冒泡的机制：人跑了 魂还在
      <div onClick={this.fn}>
        <h3>modal对话框</h3>
        <button onClick={this.open}>打开对话框</button>
        {/* {this.state.show && <Modal />} */}
        <Modal
          visible={this.state.show}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          title="新增学员"
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </div>
    );
  }
}

export default App;
